package com.oreilly.justspring.core.ch2.ex29;

import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class JMSSourceClient {
	private ApplicationContext ctx = null;

	  public JMSSourceClient() {
//	    ctx = new ClassPathXmlApplicationContext("ch2-beans.xml");
	    ctx = new FileSystemXmlApplicationContext("ch2-beans.xml");
	  }

	  public Properties getSourceProperties(){
		  JMSSource s = (JMSSource) ctx.getBean("jmsSource");
		  return s.getSourceProps();
	  }
	  
	  public List getListProperties(){
		  JMSSource s = (JMSSource) ctx.getBean("jmsSource");
		  return s.getListProperties();
	  }
	  
	  public List getSetProperties(){
		  JMSSource s = (JMSSource) ctx.getBean("jmsSource");
		  return s.getListProperties();
	  }
	  public Map getMapProperties(){
		  JMSSource s = (JMSSource) ctx.getBean("jmsSource");
		  return s.getMapProperties();
	  }
	  
	public static void main(String[] args) {
		JMSSourceClient client = new JMSSourceClient();
//		System.out.println("java.util.Properties: "+client.getSourceProperties());
//		System.out.println("List Properties: "+client.getListProperties());
//		System.out.println("Set Properties: "+client.getSetProperties());
		System.out.println("Map Properties: "+client.getMapProperties());
	}
}
